<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        body {
            background: rgba(245, 245, 245, 1);
        }

        .vueApp {
            overflow: hidden;
        }

        .m-container-mod {
            margin: 15px;
            padding: 15px;
            background: rgba(255, 255, 255, 1);
            box-shadow: 0px 1px 8px 0px rgba(0, 0, 0, 0.02);
            border-radius: 8px;
        }

        .c-hr-less {
            width: 100%;
            height: 1px;
            background-color: rgb(212, 212, 212);
            transform: scaleY(0.5);
        }

        .c-order-number {
            font-size: 15px;
            font-weight: 400;
            color: rgba(25, 25, 25, 1);
        }

        .c-order-time {
            font-size: 13px;
            font-weight: 400;
            color: rgba(128, 128, 128, 1);
            margin: 10px 0;
        }

        .o-order-goods {
            height: 80px;
            margin: 15px 0;
        }

        .c-goods-img {
            width: 60px;
            min-width: 60px;
            height: 80px;
            margin-right: 12px;
        }

        .c-goods-name {
            height: 18px;
            font-size: 14px;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
            line-height: 18px;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }

        .o-goods-sub {
            margin-top: 10px;
            height: 18px;
        }

        .c-goods-des {
            height: 18px;
            font-size: 12px;
            font-weight: 400;
            color: rgba(191, 191, 191, 1);
            line-height: 18px;
        }

        .c-goods-count {
            height: 18px;
            font-size: 12px;
            font-weight: 400;
            color: rgba(191, 191, 191, 1);
            line-height: 18px;
        }

        .c-goods-price {
            margin-top: 10px;
            height: 20px;
            font-size: 14px;
            font-weight: 600;
            color: rgba(255, 101, 24, 1);
            line-height: 20px;
        }

        .o-footer-1 {
            margin-top: 26px;
        }

        .c-footer-txt {
            width: 75px;
            font-size: 15px;
            font-weight: 400;
            color: rgba(25, 25, 25, 1);
        }

        .c-footer-money {
            font-size: 18px;
            font-weight: 500;
            color: rgba(255, 101, 24, 1);
        }

        .c-footer-tips {
            margin-top: 10px;
            font-size: 13px;
            font-weight: 400;
            color: rgba(128, 128, 128, 1);
            text-align: right;
        }

        .tips  {
            padding-top: 10.5rem;
            color: #000;
            font-size: 14px;
            font-weight: 400;
        }
    </style>

</head>

<body>
    <div class="vueApp" v-cloak>
        <div class="m-container-mod" v-for="item in listData" @click="fnGetVideoInfo(item)">
            <div class="c-order-number">订单编号:{{ item.orderSn }}</div>
            <div class="c-order-time">{{ transformCreateDate(item.paymentTime) }}</div>
            <div class="c-hr-less"></div>
            <div class="o-order-goods" data-flex>
                <img class="c-goods-img" :src="item.pic" alt="">
                <div data-flex-box="1">
                    <div class="c-goods-name">{{ item.goodsName }}</div>
                    <div class="o-goods-sub" data-flex="main:justify"></div>
                    <div class="c-goods-price">¥{{ item.totalAmount || 0 }}</div>
                </div>
            </div>
            <div class="c-hr-less"></div>
            <div class="o-footer-1" data-flex="main:right cross:center">
                <div class="c-footer-txt">支付金额:</div>
                <div class="c-footer-money">¥{{ item.payAmount }}</div>
            </div>
            <!-- <div class="c-footer-tips">日前生效</div> -->
        </div>
        <div class="tips" v-show="tipsShow" data-flex="main:center cross:center">
            当前没有更多数据了
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm;
    apiready = function () {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');
        fnInit();
    };
    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                pageNo: 1,
                pageSize: 10,
                listData: [],
                tipsShow: false
            },
            methods: {
                transformDate: function (date) {
                    return formatTime(date, 'date');
                },
                transformCreateDate: function (date) {
                    return formatTime(date,'order_data');
                }
            }
        });
        load();
    }

    function load() {
        getPageData('headerRefreshing');
        fnAddHeaderRefreshingEvent(function () { //设置下拉刷新
            getPageData('headerRefreshing');
        });

        fnAddFooterLoadingEvent(function () { // 设置上拉加载
            getPageData('load');
        });
    }

    function getPageData(sign) {
        if (sign == 'headerRefreshing') {
            vm.pageNo = 1;
        } else {
            vm.pageNo++;
        }
        var url = 'videos/findOrderByMember';
        var params = {
            "pageNo": vm.pageNo,
            "pageSize": vm.pageSize
        };
        var callback = function (data) {
            if (vm.pageNo == '1') {
                vm.listData = [];
            }
            api.refreshHeaderLoadDone();
            vm.listData = vm.listData.concat(data.listData);
            vm.$nextTick(function() {
                if(vm.listData.length === 0) {
                    vm.tipsShow = true;
                } else {
                    vm.tipsShow = false;
                }
            })
            // status 为200时,只返回data
        };
        POST(url, params, callback);
    }

    function handleItem(item) {
        fnOpenPublicWin('视频详情', 'video/detail', {
            productsId: item.goodsId,
            videoId: item.videoId,
            isSlidBack: false
        });
    }

    function fnGetVideoInfo(item) {
        var params = {
            id: item.goodsId
        };
        var callback = function(data) {
            if(data.errorStatus == 19999) {
                fnToast(data.errorMessage);
            }else {
                if(item.goodsId == data.videoId) {
                    // 套集
                }else {
                    // 单集
                    item.videoId = item.goodsId +'';
                    item.goodsId = data.videoId;
                }
                handleItem(item)
            }
        };
        POST('my/returnVideoId', params, callback)
    }
</script>

</html>